<!DOCTYPE html>
<html>
<head>
    <title>内部邮件</title>
    <%include("/app/resapi/mobilestyle.html"){}%>
    <link rel="stylesheet" type="text/css" href="/module/zTree_v3/css/bootstrapStyle/bootstrapStyle.css">
    <style type="text/css">
        .list-item {
            height: 100px;
        }
    </style>
</head>
<body>
<div align="left" style="width:100%;text-align: center">
    <a href="/mobile/email/index" class="btn btn-default">邮件列表</a>
    <a href="/app/core/oa/email?view=msendemail" class="btn btn-purple">编写邮件</a>
</div>
<section class="g-flexview">
    <section class="g-scrollview">
        <div class="m-cell">
            <div class="cell-item">
                <div class="cell-left">邮件标题：</div>
                <div class="cell-right"><input id="subject" type="text" class="cell-input" placeholder="邮件标题"></div>
            </div>
            <div class="cell-item">
                <div class="cell-left">收件人：</div>
                <div class="cell-right"><input id="toId" type="text" class="cell-input" placeholder="收件人" opt-id="toId" onclick="selectUser(this,'true');"></div>
            </div>
            <div class="cell-item" style="padding: 0.24rem;">
                <textarea class="form-control" rows="5" id="content"></textarea>
            </div>
            <div class="cell-item">
                <div class="cell-left">${i18n('attach')}：</div>
                <div class="cell-right">
                    <div id="show_diaryattach"></div>
                    <a class="addfile" href="javascript:void(0)">${i18n('fileupload')} <input data_value="" type="file" onchange="fileUpLoad('diary','diaryattach');" hidefocus="true" size="1" id="diaryattach"
                                                                                              name="diaryattach" class="addfile" multiple="multiple"></a>

                </div>
            </div>
            <div class="cell-item" style="margin-top: 20px;padding: 0.24rem;padding-bottom: 20px;" align="center">
                <a href="javascript:void(0);" class="btn btn-sky shiny js-save" style="width:100%">${i18n('save')}</a>
            </div>
        </div>
    </section>
</section>
<div id="orgselectdiv"></div>
<%include("/app/resapi/mobilejs.html"){}%>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="/module/fileupload/ajaxfileupload.js"></script>
<script type="text/javascript" src="/module/orgselect/orgselect.js"></script>
<script type="text/javascript" src="/module/fileupload/mobilefileupload.js"></script>
<script>
    var dialog = YDUI.dialog;
    $(function () {
        $(".js-save").unbind("click").click(function () {
            sendEmail();
        })
    })

    function sendEmail() {
        if ($("#toId").attr("data-value") == "@all") {
            dialog.alert('邮件不能发送全体人员！');
        } else {
            $.ajax({
                url: "/set/oaset/sendEmail",
                type: "post",
                dataType: "json",
                data: {
                    subject: $("#subject").val(),
                    toId: $("#toId").attr("data-value"),
                    content: $("#content").val(),
                    attach: $("#diaryattach").attr("data_value")
                },
                success: function (data) {
                    if (data.status == "200") {
                        window.location.reload();
                    } else if (data.status == "100") {
                        layer.msg(data.msg);
                    } else {
                        console.log(data.msg);
                    }
                }
            });
        }
    }
</script>
</body>
</html>
